package schedule;

import action.ActionSInterface;

/**
 * 
 * @author Minodor Detects Time collisions in a schedule;
 */
public class CollisionDetector {

	private static boolean checkTimers(ActionSInterface current,
			ActionSInterface next) {
		if (current.getEndTimer() <= next.getStartTimer())
			return true;
		else
			return false;
	}

	public static int validate(Schedule s) {
		boolean verified = true;
		for (int index = 0; index < s.getActionsCount() - 1; index++) {
			ActionSInterface current = s.get(index);
			ActionSInterface next = s.get(index + 1);
			verified = checkTimers(current, next);
			if (verified == false)
				return index;

		}
		return (-1);
	}
}
